package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.basedoc.model.OrgBuilding;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.DestnBuilding;
import com.eling.elcms.travel.service.IDestnBuildingManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DestnBuildingController extends BaseFormController {

	@Autowired
	IDestnBuildingManager destnBuildingManagerd;

	@RequestMapping("/api/destnbuilding/search*")
	@ResponseBody
	public List<DestnBuilding> sreach(@ModelAttribute SearchCondition sc, @ModelAttribute DestnBuilding cond) {
		sc.setQueryCondition(cond);
		return destnBuildingManagerd.search(sc);
	}

	@RequestMapping("/api/destnbuilding/query")
	@ResponseBody
	public List<DestnBuilding> query(@ModelAttribute DestnBuilding cond) {
		return destnBuildingManagerd.query(cond);
	}

	@RequestMapping("/api/destnbuilding/save")
	@ResponseBody
	public DestnBuilding save(@ModelAttribute @ModelFilling DestnBuilding cond) {
		return destnBuildingManagerd.save(cond);
	}

	@RequestMapping("/api/destnbuilding/{pkDestnBuilding}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkDestnBuilding) {
		destnBuildingManagerd.remove(pkDestnBuilding);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/destnbuilding/querybuilding")
	@ResponseBody
	public List<OrgBuilding> queryBuilding(@ModelAttribute OrgBuilding cond) {
		return destnBuildingManagerd.queryBuilding(cond);
	}

}
